package com.bobo.util;


import java.lang.reflect.Field;
import java.sql.Date;
import java.sql.Timestamp;
import java.util.*;

/**
 * Created by bobo on 16-11-13.
 */
public class Utils {


    /**
     * 首字母大写
     * @param str
     * @return
     */
    public static String captureName(String str) {
        byte[] items = str.getBytes();
        items[0] = (byte) ((char) items[0] - 'a' + 'A');

        return new String(items);
    }

    /**
     * 首字母小写
     * @param s
     * @return
     */
    public static String toLower(String s) {
        if (Character.isLowerCase(s.charAt(0)))
            return s;
        else
            return (new StringBuilder()).append(Character.toLowerCase(s.charAt(0))).append(s.substring(1)).toString();
    }


    public static boolean isBaseDataType(Class clazz) throws Exception {
        return (
                    clazz.equals(String.class) ||
                    clazz.equals(Integer.class) ||
                    clazz.equals(Byte.class) ||
                    clazz.equals(Long.class) ||
                    clazz.equals(Double.class) ||
                    clazz.equals(Float.class) ||
                    clazz.equals(Character.class) ||
                    clazz.equals(Short.class) ||
                    clazz.equals(Boolean.class) ||
                    clazz.equals(Date.class) ||
                    clazz.equals(Timestamp.class) ||
                    clazz.isPrimitive()
                );
    }


    public static boolean isCollection(Class clz) {

        return   (clz.equals(Map.class) || clz.equals(List.class) || clz.equals(Vector.class) || clz.equals(Hashtable.class))  ;

    }

    /**
     * 判断是否为实体类
     * @param field
     * @return
     */
    public static boolean isModel(Field field) {

        return field.getType().toString().contains("com.bobo.model");
    }

    public static boolean isModelC(Class clz) {

        return clz.toString().contains("com.bobo.model");
    }


}
